Imports NENAData.LINQ
Imports NENAData.NENAProvinces
Imports NENAData.Transactions

Partial Class RenewMembership
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If Not IsPostBack Then
            BindMemberData()
        End If

    End Sub

    Private Sub BindMemberData()
        Dim x As New NENATransactions

        ListViewIncompleteTransactions.DataSource = x.GetAvailableTransactions(CType(Session("Member_ID"), Integer))
        ListViewIncompleteTransactions.DataBind()

    End Sub

    Protected Function Incomplete() As List(Of Transaction)
        Dim x As New NENATransactions
        Return x.GetAvailableTransactions(CType(Session("Member_ID"), Integer))

    End Function
    Protected Sub ViewReciept()
        Response.Redirect("reciept.aspx")
    End Sub

    Protected Sub ListViewIncompleteTransactions_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
        If checkVerify.Checked = False Then
            lblMessage.Text = "You must verify your demographics are up to date before making payments.<br/>Click the above checkbox if our data is correct"
            Exit Sub
        End If
        Dim oAffiliate As Affiliate
        Dim oNENAAffiliate As New NENAAffiliate

        oAffiliate = oNENAAffiliate.GetCurrentAffiliate_byTransactionID_byMemberID(e.CommandArgument.ToString, CType(Session("Member_ID"), Integer))
        'lblMessage.Text = "fee = " & String.Format("{0:00.00}", oAffiliate.Membership_Fee)

        Select Case e.CommandName
            Case "PaybyOther"
                'lblMessage.Text = "other " & e.CommandArgument.ToString
                Response.Redirect("http://membership.nena.ca/ApplicationFormCompleted.aspx?Member_ID=" & Session("Member_ID") & "&Account_Status=" & MemberStatus.Status.Renewing & "&Affiliate_ID=" & oAffiliate.Affiliate_ID)

            Case "PaybyPalPal"
                'lblMessage.Text = "paypal " & e.CommandArgument.ToString
                Response.Redirect("http://membership.nena.ca/paypal/expresscheckout.aspx?Member_ID=" & Session("Member_ID") & "&Payment_amt=" & _
                                  String.Format("{0:00.00}", oAffiliate.Membership_Fee) & "&Affiliate_ID=" & oAffiliate.Affiliate_ID & "&TransactionID_NENA=" & e.CommandArgument.ToString)
            Case Else
                lblMessage.Text = ""
        End Select

    End Sub

    Protected Function GetFeebyTransactionType(ByVal strType As String) As String
        Select Case strType
            Case "Membership"
                Dim x As New NENAAffiliate
                Dim oAffiliate As Affiliate

                oAffiliate = x.GetAffiliate_byMemberID(CType(Session("Member_ID"), Integer))

                Return "Membership Fee for " & oAffiliate.Affiliate_Full & "(" & oAffiliate.Affiliate_Description & ") is " & String.Format("{0:C}", oAffiliate.Membership_Fee)
            Case Else
                Return "not membership"
        End Select
    End Function

    Protected Function GetTransactionType(ByVal strType As String) As String
        Select Case strType
            Case "Membership"
                Dim x As New NENAAffiliate
                Dim oAffiliate As Affiliate

                oAffiliate = x.GetAffiliate_byMemberID(CType(Session("Member_ID"), Integer))

                Return "Paid Membership Fee to " & oAffiliate.Affiliate_Full & "(" & oAffiliate.Affiliate_Description & ") "
            Case Else
                Return "not membership"
        End Select
    End Function

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Response.Redirect("default.aspx")
    End Sub

End Class
